<template>
	<div class="record-item">
		<div class="title">
			<h3>房屋编号：{{ details?.fwbh }}</h3>
		</div>
		<div class="item" v-for="(value, key) in dataEnum" :key="key">
			<p>{{ value === '时间' ? `${details?.yhly}时间` : value   }}</p>
			<p>{{ details?.[key] || '-' }}</p>
		</div>
		<div class="btns">
			<div @click="toPage(4)">核验记录</div>
			<div @click="toPage(1)">自查记录</div>
			<div @click="toPage(2)">检查记录</div>
			<div @click="toPage(3)">隐患记录</div>
		</div>
	</div>
</template>

<script setup>
import { defineEmits, defineProps } from 'vue'
import { useRouter } from 'vue-router'

const props = defineProps({
	details: {
		type: Object,
		default: () => {}
	},
	date: {
		type: Object,
		default: () => []
	}
})
const emits = defineEmits(['beforeLeave'])

const router = useRouter()
const dataEnum = {
	'hzxm': '房主姓名',
	'address': '地址',
	// 'createOn': '时间',
	// 'pczt': '有无隐患',
}
const statusImg = {
	'无隐患': require('./../image/trouble_no.png'),
	'有隐患': require('./../image/trouble_has.png'),
}

const toPage = (type) => {
	emits('beforeLeave')
	if (type !== 4) {
		router.push({
			name: 'check-record-record-type',
			query: {
				type,
				id: props.details?.fwbh,
				date: JSON.stringify(props.date)
			}
		})
	} else {
		router.push({
			name: 'verification-record-record-type',
			query: {
				type: 2,
				id: props.details?.fwbh,
				date: JSON.stringify(props.date)
			}
		})
	}
}

</script>

<style scoped lang="less">
.record-item {
	margin: 0 32px 24px;
	padding: 24px 32px;
	box-shadow: 0 0 16px 0 rgba(0, 0, 0, .14);
	border-radius: 8px;
	background: #fff;
	h3 {
		margin-bottom: 22px;
	}
	.title {
		display: flex;
		img {
			width: 48px;
			height: 48px;
			margin-right: 12px;
		}
		h3 {
			width: 0;
			flex: 1;
			min-height: 48px;
			line-height: 48px;
		}
	}
	.item {
		display: flex;
		margin-top: 4px;
		p {
			min-height: 44px;
			line-height: 44px;
			&:nth-of-type(1) {
				width: 160px;
				color: #A0A0A0;
			}
			&:nth-of-type(2) {
				width: 0;
				flex: 1;
				color: #696969;
			}
		}
	}
	.btns {
		display: flex;
		justify-content: flex-end;
		gap: 24px;
		border-top: 2px solid var(--border-color);
		margin-top: 24px;
		padding-top: 20px;
		div {
			height: 50px;
			line-height: 50px;
			background: var(--van-primary-color);
			color: #fff;
			border-radius: 12px;
			padding: 0 12px;
		}
	}
}
</style>
